<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/pageHead.jsp"%>
<script type="text/javascript">
	function view(val){
		var id = val;
		$(this).isswindow({
			noheader : true,
			url :"${systemctx}/dailyoperation/store/storeView.web?id="+id
		});
	}
	function query_datagrid(){
		//加载分页控件 datagrid
		$('#datagrid').issdatagrid({
			formid : 'form1',
			title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.list.title")%>',
			width : 'auto',
			nowrap : true,
			autoRowHeight : false,
			singleSelect : true,
			striped : true,
			url : '${systemctx}/dailyoperation/store/getStoreListJson.json?',
			sortName : 'modifytime',
			sortOrder : 'desc',
			remoteSort : true,
			idField : 'id',
			pagination : true,
			rownumbers : true,
			showFooter : true,
			queryParams:$('#form1').serializeObject(),
			frozenColumns :[[
				{field : 'id',title : '<%=MessageResourcesUtils.getMessage(request, "common.button.operation")%>',width : 90,align : 'center',formatter : function(val, row,index) {
						var str = ""; 
						if(row.state=="<%=SysConstant.CommonApproveStatus.getStateName(SysConstant.CommonApproveStatus.SAVED)%>" || row.state=="<%=SysConstant.CommonApproveStatus.getStateName(SysConstant.CommonApproveStatus.REFUSED)%>"){
							str = '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="editInfo(' + row.id + ')"><%=MessageResourcesUtils.getMessage(request, "common.button.update")%></a>  ';
						str  +='<a href="javascript:void(0);" class="easyui-linkbutton" onclick="deleteInfo(' + row.id + ')"><%=MessageResourcesUtils.getMessage(request, "common.button.delete")%></a> ';
						}else {
							str = '<a disabled="disabled" class="easyui-linkbutton disabled" style="color:grey"><%=MessageResourcesUtils.getMessage(request, "common.button.update")%></a>  ';
						str  +='<a disabled="disabled" class="easyui-linkbutton disabled" style="color:grey"><%=MessageResourcesUtils.getMessage(request, "common.button.delete")%></a> ';
						}
					return str;
				}},
				{title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.number")%>',field : 'number',sortable : true,align : 'left',formatter: function(value,row,index){
					return "<a href=\"javascript:void(0);\" onclick=\"view('"+row.id+"')\">"+value+"</a>";
				}
				},  
				{title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.name")%>',field : 'name',sortable : true,align : 'left',width:200,formatter: function(value,row,index){
					return "<span title='"+value+"'>"+value+"</span>";					
				}}, 
				{title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.corporate")%>',field : 'corporate',sortable : true,align : 'left',width:120}
            ]],
			columns : [[ 
              	{title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.quality")%>',field : 'quality',sortable : true,align : 'left',width:80}, 
              	{title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.population")%>',field : 'population',sortable : true,align : 'left',width:80}, 
              	{title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.industry")%>',field : 'industry',sortable : true,align : 'left',width:120}, 
              	
              	{title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.businesslicensecode")%>',field : 'businesslicensecode',sortable : true,align : 'left',width:160}, 
              	{title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.organizationcode")%>',field : 'organizationcode',sortable : true,align : 'left',width:160}, 
              	{title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.certificatecode")%>',field : 'certificatecode',sortable : true,align : 'left',width:160}, 
              	
              	{title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.realname")%>',field : 'realname',sortable : true,align : 'left',width:150,formatter: function(value,row,index){
					return "<span title='"+value+"'>"+value+"</span>";					
				}} ,
              	{title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.state")%>',field : 'state',sortable : true,align : 'center',width:60}
              	<%-- {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.bussisstatus")%>',field : 'businessstatus',sortable : true,align : 'center',width:70}, --%> 
            ]],
			onLoadSuccess : function(data) {

			}
		});
	}

	$(document).ready(function() {
		$("#state").selectutil({
			optModel : <%=SysConstant.CommonApproveStatus.getMode1JSONString(true, false)%>
		});
		query_datagrid();
		$('#butQuery').click(function() {
			$('#datagrid').datagrid('load',$('#form1').serializeObject());
		});

		$('#butRest').click(function() {
			$('#currencynum').val('');
			$('#currencyname').val('');
		});

	});
	
	function addStoreInfo(){
		$(this).isswindow({
			noheader : true,
			url :"${systemctx}/dailyoperation/store/intoStoreInfo.web"
		});
	}
	function deleteInfo(id){
		var ids = id;
		if (ids != '' && ids != undefined) {
			var statu = confirm("<%=MessageResourcesUtils.getMessage(request, "common.message.alert")%>");
		    if(!statu){
		        return false;
		    }else {
		    	// 显示进度条
				showSending();
				$.ajax({
					type: 'POST',
				    url: '${systemctx}/dailyoperation/store/delete.web?ids='+ids,
				    data: $("#form1").serialize(),
				    dataType: 'json',
				    success: function(data) {
				    	//关闭执行...
						closeSending();
				    	if(data.code == 200){
				    		alert("<%=MessageResourcesUtils.getMessage(request, "common.alert.success")%>");
				    		<%-- messageAlert("<%=MessageResourcesUtils.getMessage(request, "common.alert.success")%>"); --%>
				    		query_datagrid();
				    	}else {
				    		messageAlert(data.message);
				    	}
				    }
				});
		    }
		}
	}
	function editInfo(flag){
		var ids = flag;
		if (ids != '' && ids != undefined) {
			$(this).isswindow({
				noheader : true,
				url :"${systemctx}/dailyoperation/store/storeEdit.web?id="+ids
			});
		}
	}
	
	function getIds(flag) {
		var ids = "";
		var rows = $('#datagrid').datagrid('getChecked');
		if (rows.length == 0) {
			messageAlert("<%=MessageResourcesUtils.getMessage(request, "dailyoperation.selects.warning")%>");
			return;
		} else {
			if (flag == 1) {
				if (rows.length > 1) {
					messageAlert("<%=MessageResourcesUtils.getMessage(request, "dailyoperation.selects.edit.warning")%>");
					return;
				} else {
					ids = rows[0].id;
					return ids;
				}
			} else {
				for (var i = 0; i < rows.length; i++) {
					ids += rows[i].id + ",";
				}
				if (ids != '') {
					ids = ids.substring(0,ids.length - 1);
				}
				return ids;
			}
		}
	}
	
</script>

<form name="form1" id="form1">
	<div class="pageMain">
		<div class="pageTitle">
			<%=MessageResourcesUtils.getMessage(request, "systemmanage.storemanagement.title") %>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.register.title") %>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.list") %>
		</div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.name") %>
						</label>
						<span><input type="text" name="name" id="name"></span>
					</li>
					<li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.state") %>:
						</label>
						<span><select name="state" id="state"></select></span>
					</li>
				</ul>
			</div>	
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" id="butQuery"  value="<%=MessageResourcesUtils.getMessage(request,"common.button.query") %>" />
			<input type="button" class="btn btn-default" onclick="addStoreInfo()" value="<%=MessageResourcesUtils.getMessage(request,"common.button.add") %>" />
		</div>
		<table width="100%">
			<tbody>
				<tr>
					<td>
						<table id="datagrid"></table>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form>

<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>